<?php

namespace app\goods\controller;

use app\BaseController;
use app\model\Goods;

class Commend extends BaseController
{
    /**
     * 根据参数随机获取商品
     *
     * @return Array
     */
    public function index()
    {
        $limit = $this->request->param('limit');
        $DBgoods = new Goods();
        $goodsInfo = $DBgoods->orderRaw('rand()')->limit($limit)->select();
        if ($goodsInfo) {
            return result($goodsInfo);
        } else {
            return result(null, '未查询到相关数据');
        }
    }
}